What is Icevision ?

Icevision is a framework agnostic object detection library that enables us to train our models with just a few lines using fastai or pytorch lightning.Icevision makes training mmdetection,torchvision and efficientdet models extremely easy.All we need to do is change a couple lines.Let's get started.

Installation

We start by installing Icevision.Installing Icevision is pretty easy,all we need to do is run the cell below.Beware that we are running on colab using gpu.If you are on your local machine and need to use cpu,change the below line from cuda to cpu.Icevision only supports Linux and MAC at the moment(via installation below) but you can install its dependencies manually to run it on Windows.We also install torch,torchvision,mmdetection,yolov5 and efficientdet in the cell below.

# Torch - Torchvision - IceVision - IceData - MMDetection - YOLOv5 - EfficientDet Installation
!wget https://raw.githubusercontent.com/airctic/icevision/master/icevision_install.sh

# Choose your installation target: cuda11 or cuda10 or cpu
!bash icevision_install.sh cuda11 master

--2022-08-07 15:54:31--  https://raw.githubusercontent.com/airctic/icevision/master/icevision_install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2820 (2.8K) [text/plain]
Saving to: ‘icevision_install.sh’

icevision_install.s 100%[===================>]   2.75K  --.-KB/s    in 0s      

2022-08-07 15:54:31 (26.6 MB/s) - ‘icevision_install.sh’ saved [2820/2820]

Installing icevision + dependencices for cuda11
- Installing torch and its dependencies
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.10.0+cu111
  Downloading https://download.pytorch.org/whl/cu111/torch-1.10.0%2Bcu111-cp37-cp37m-linux_x86_64.whl (2137.6 MB)
     |████████████▌                   | 834.1 MB 1.5 MB/s eta 0:14:30tcmalloc: large alloc 1147494400 bytes == 0x3a39c000 @  0x7f3db06e5615 0x592b76 0x4df71e 0x59afff 0x515655 0x549576 0x593fce 0x548ae9 0x51566f 0x549576 0x593fce 0x548ae9 0x5127f1 0x598e3b 0x511f68 0x598e3b 0x511f68 0x598e3b 0x511f68 0x4bc98a 0x532e76 0x594b72 0x515600 0x549576 0x593fce 0x548ae9 0x5127f1 0x549576 0x593fce 0x5118f8 0x593dd7
     |███████████████▉                | 1055.7 MB 1.4 MB/s eta 0:12:46tcmalloc: large alloc 1434370048 bytes == 0x7e9f2000 @  0x7f3db06e5615 0x592b76 0x4df71e 0x59afff 0x515655 0x549576 0x593fce 0x548ae9 0x51566f 0x549576 0x593fce 0x548ae9 0x5127f1 0x598e3b 0x511f68 0x598e3b 0x511f68 0x598e3b 0x511f68 0x4bc98a 0x532e76 0x594b72 0x515600 0x549576 0x593fce 0x548ae9 0x5127f1 0x549576 0x593fce 0x5118f8 0x593dd7
     |████████████████████            | 1336.2 MB 53.1 MB/s eta 0:00:16tcmalloc: large alloc 1792966656 bytes == 0x3824000 @  0x7f3db06e5615 0x592b76 0x4df71e 0x59afff 0x515655 0x549576 0x593fce 0x548ae9 0x51566f 0x549576 0x593fce 0x548ae9 0x5127f1 0x598e3b 0x511f68 0x598e3b 0x511f68 0x598e3b 0x511f68 0x4bc98a 0x532e76 0x594b72 0x515600 0x549576 0x593fce 0x548ae9 0x5127f1 0x549576 0x593fce 0x5118f8 0x593dd7
     |█████████████████████████▎      | 1691.1 MB 1.4 MB/s eta 0:05:25tcmalloc: large alloc 2241208320 bytes == 0x6e60c000 @  0x7f3db06e5615 0x592b76 0x4df71e 0x59afff 0x515655 0x549576 0x593fce 0x548ae9 0x51566f 0x549576 0x593fce 0x548ae9 0x5127f1 0x598e3b 0x511f68 0x598e3b 0x511f68 0x598e3b 0x511f68 0x4bc98a 0x532e76 0x594b72 0x515600 0x549576 0x593fce 0x548ae9 0x5127f1 0x549576 0x593fce 0x5118f8 0x593dd7
     |████████████████████████████████| 2137.6 MB 1.4 MB/s eta 0:00:01tcmalloc: large alloc 2137645056 bytes == 0xf3f6e000 @  0x7f3db06e41e7 0x4a3940 0x4a39cc 0x592b76 0x4df71e 0x59afff 0x515655 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x593dd7 0x511e2c 0x549576 0x593fce 0x548ae9 0x5127f1 0x549576 0x593fce 0x548ae9
tcmalloc: large alloc 2672058368 bytes == 0x1e7ac4000 @  0x7f3db06e5615 0x592b76 0x4df71e 0x59afff 0x515655 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x549576 0x593fce 0x511e2c 0x593dd7 0x511e2c 0x549576 0x593fce 0x548ae9 0x5127f1 0x549576 0x593fce 0x548ae9 0x5127f1 0x549576
     |████████████████████████████████| 2137.6 MB 222 bytes/s 
Collecting torchvision==0.11.1+cu111
  Downloading https://download.pytorch.org/whl/cu111/torchvision-0.11.1%2Bcu111-cp37-cp37m-linux_x86_64.whl (24.5 MB)
     |████████████████████████████████| 24.5 MB 71.3 MB/s 
Collecting torchtext==0.11.0
  Downloading torchtext-0.11.0-cp37-cp37m-manylinux1_x86_64.whl (8.0 MB)
     |████████████████████████████████| 8.0 MB 25.4 MB/s 
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from torch==1.10.0+cu111) (4.1.1)
Requirement already satisfied: pillow!=8.3.0,>=5.3.0 in /usr/local/lib/python3.7/dist-packages (from torchvision==0.11.1+cu111) (7.1.2)
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from torchvision==0.11.1+cu111) (1.21.6)
Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from torchtext==0.11.0) (4.64.0)
Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from torchtext==0.11.0) (2.23.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->torchtext==0.11.0) (2022.6.15)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->torchtext==0.11.0) (2.10)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->torchtext==0.11.0) (1.24.3)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->torchtext==0.11.0) (3.0.4)
Installing collected packages: torch, torchvision, torchtext
  Attempting uninstall: torch
    Found existing installation: torch 1.12.0+cu113
    Uninstalling torch-1.12.0+cu113:
      Successfully uninstalled torch-1.12.0+cu113
  Attempting uninstall: torchvision
    Found existing installation: torchvision 0.13.0+cu113
    Uninstalling torchvision-0.13.0+cu113:
      Successfully uninstalled torchvision-0.13.0+cu113
  Attempting uninstall: torchtext
    Found existing installation: torchtext 0.13.0
    Uninstalling torchtext-0.13.0:
      Successfully uninstalled torchtext-0.13.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchaudio 0.12.0+cu113 requires torch==1.12.0, but you have torch 1.10.0+cu111 which is incompatible.
Successfully installed torch-1.10.0+cu111 torchtext-0.11.0 torchvision-0.11.1+cu111
- Installing mmcv
     |████████████████████████████████| 51.3 MB 136 kB/s 
     |████████████████████████████████| 190 kB 29.4 MB/s 
- Installing mmdet
     |████████████████████████████████| 1.2 MB 32.1 MB/s 
- Installing mmseg
     |████████████████████████████████| 686 kB 26.6 MB/s 
- Installing icevision from master
     |████████████████████████████████| 3.1 MB 28.7 MB/s 
     |████████████████████████████████| 55 kB 4.3 MB/s 
     |████████████████████████████████| 98 kB 8.3 MB/s 
     |████████████████████████████████| 49 kB 5.6 MB/s 
     |████████████████████████████████| 111 kB 62.9 MB/s 
     |████████████████████████████████| 97 kB 5.0 MB/s 
     |████████████████████████████████| 798 kB 16.6 MB/s 
     |████████████████████████████████| 58 kB 3.9 MB/s 
     |████████████████████████████████| 188 kB 47.1 MB/s 
     |████████████████████████████████| 700 kB 11.2 MB/s 
     |████████████████████████████████| 1.8 MB 52.8 MB/s 
     |████████████████████████████████| 79 kB 7.7 MB/s 
     |████████████████████████████████| 509 kB 59.6 MB/s 
     |████████████████████████████████| 596 kB 54.3 MB/s 
     |████████████████████████████████| 117 kB 50.4 MB/s 
     |████████████████████████████████| 141 kB 41.3 MB/s 
     |████████████████████████████████| 5.8 MB 52.6 MB/s 
     |████████████████████████████████| 419 kB 56.2 MB/s 
     |████████████████████████████████| 50 kB 6.3 MB/s 
     |████████████████████████████████| 42 kB 1.0 MB/s 
     |████████████████████████████████| 154 kB 41.8 MB/s 
     |████████████████████████████████| 87 kB 7.2 MB/s 
     |████████████████████████████████| 97 kB 7.0 MB/s 
     |████████████████████████████████| 181 kB 48.2 MB/s 
     |████████████████████████████████| 157 kB 46.2 MB/s 
     |████████████████████████████████| 63 kB 1.5 MB/s 
     |████████████████████████████████| 157 kB 46.9 MB/s 
     |████████████████████████████████| 156 kB 68.4 MB/s 
  Building wheel for icevision (setup.py) ... done
  Building wheel for antlr4-python3-runtime (setup.py) ... done
  Building wheel for fire (setup.py) ... done
  Building wheel for fvcore (setup.py) ... done
  Building wheel for iopath (setup.py) ... done
  Building wheel for pathtools (setup.py) ... done
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.8.2+zzzcolab20220719082949 requires tensorboard<2.9,>=2.8, but you have tensorboard 2.9.1 which is incompatible.
flask 1.1.4 requires click<8.0,>=5.1, but you have click 8.0.4 which is incompatible.
- Installing icedata from master
  Building wheel for icedata (setup.py) ... done
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting opencv-python-headless==4.1.2.30
  Downloading opencv_python_headless-4.1.2.30-cp37-cp37m-manylinux1_x86_64.whl (21.8 MB)
     |████████████████████████████████| 21.8 MB 1.3 MB/s 
Requirement already satisfied: numpy>=1.14.5 in /usr/local/lib/python3.7/dist-packages (from opencv-python-headless==4.1.2.30) (1.21.6)
Installing collected packages: opencv-python-headless
  Attempting uninstall: opencv-python-headless
    Found existing installation: opencv-python-headless 4.6.0.66
    Uninstalling opencv-python-headless-4.6.0.66:
      Successfully uninstalled opencv-python-headless-4.6.0.66
Successfully installed opencv-python-headless-4.1.2.30
icevision installation finished!
# We need to restart the kernel after installation
import IPython
IPython.Application.instance().kernel.do_shutdown(True)

Imports

We can import everything we need with just 'from icevision.all import *'.

from icevision.all import *
INFO     - Downloading default `.ttf` font file - SpaceGrotesk-Medium.ttf from https://raw.githubusercontent.com/airctic/storage/master/SpaceGrotesk-Medium.ttf to /root/.icevision/fonts/SpaceGrotesk-Medium.ttf | icevision.visualize.utils:get_default_font:70
INFO     - Downloading mmdet configs | icevision.models.mmdet.download_configs:download_mmdet_configs:31
Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...
INFO     - Downloading mmseg configs | icevision.models.mmseg.download_configs:download_mmseg_configs:33

Lets download a sample dataset from Icevision.

In the near future,we will work with our custom datasets for our custom needs.

url = "https://cvbp-secondary.z19.web.core.windows.net/datasets/object_detection/odFridgeObjects.zip"
dest_dir = "fridge"
data_dir = icedata.load_data(url, dest_dir)

Dataset Parsing

Icevision has very neat tricks for parsing both VOC and COCO type datasets.It can also identify our annotation errors and corrects them automatically.This capability is called 'autofix'.Records is a very important concept in Icevision that holds information about image and its annotation.It is very extensible and can be customized for other object annotation types.

parser = parsers.VOCBBoxParser(annotations_dir=data_dir / "odFridgeObjects/annotations", images_dir=data_dir / "odFridgeObjects/images")
train_records, valid_records = parser.parse()
parser.class_map
INFO     - Autofixing records | icevision.parsers.parser:parse:122
<ClassMap: {'background': 0, 'carton': 1, 'milk_bottle': 2, 'can': 3, 'water_bottle': 4}>

Augmentations

'Data augmentations are essential for robust training and results on many datasets and deep learning tasks. IceVision ships with the Albumentations library for defining and executing transformations, but can be extended to use others. For this tutorial, we apply the Albumentation's default aug_tfms to the training set. aug_tfms randomly applies broadly useful transformations including rotation, cropping, horizontal flips, and more. See the Albumentations documentation to learn how to customize each transformation more fully. The validation set is only resized (with padding). We then create Datasets for both. The dataset applies the transforms to the annotations (such as bounding boxes) and images in the data records.'

# size is set to 384 because EfficientDet requires its inputs to be divisible by 128
image_size = 384
train_tfms = tfms.A.Adapter([*tfms.A.aug_tfms(size=image_size, presize=512),tfms.A.Perspective(p=0.01),tfms.A.Normalize()])
valid_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(image_size), tfms.A.Normalize()])
train_ds = Dataset(train_records, train_tfms)
valid_ds = Dataset(valid_records, valid_tfms)

Understanding the transforms

'The Dataset transforms are only applied when we grab (get) an item. Several of the default aug_tfms have a random element to them. For example, one might perform a rotation with probability 0.5 where the angle of rotation is randomly selected between +45 and -45 degrees. This means that the learner sees a slightly different version of an image each time it is accessed. This effectively increases the size of the dataset and improves learning. We can look at result of getting the 0th image from the dataset a few times and see the differences. Each time you run the next cell, you will see different results due to the random element in applying transformations.' You can add your custom albumentation transforms to train_tfms just as I did with 'tfms.A.Perspective'.

samples = [train_ds[0] for _ in range(3)]
show_samples(samples, ncols=3)

Selecting a Library and a Model

It is time to select our model ! We have a lot of options but I recommend you to try one of the mmdetection library models because they have a lot of state of the art implementations of models(Especially Vfnet).

Creating a model

'Selections only take two simple lines of code. For example, to try the mmdet library using the retinanet model and the resnet50_fpn_1x backbone could be specified by:model_type = models.mmdet.retinanetbackbone = model_type.backbones.resnet50_fpn_1x(pretrained=True) As pretrained models are used by default, we typically leave this out of the backbone creation step.'

selection = 0

extra_args = {}

if selection == 0:
  model_type = models.mmdet.vfnet
  backbone = model_type.backbones.resnet50_fpn_mstrain_2x

if selection == 1:
  model_type = models.mmdet.retinanet
  backbone = model_type.backbones.resnet50_fpn_1x
  # extra_args['cfg_options'] = { 
  #   'model.bbox_head.loss_bbox.loss_weight': 2,
  #   'model.bbox_head.loss_cls.loss_weight': 0.8,
  #    }

if selection == 2:
  model_type = models.mmdet.faster_rcnn
  backbone = model_type.backbones.resnet101_fpn_2x
  # extra_args['cfg_options'] = { 
  #   'model.roi_head.bbox_head.loss_bbox.loss_weight': 2,
  #   'model.roi_head.bbox_head.loss_cls.loss_weight': 0.8,
  #    }

if selection == 3:
  model_type = models.mmdet.ssd
  backbone = model_type.backbones.ssd300

if selection == 4:
  model_type = models.mmdet.yolox
  backbone = model_type.backbones.yolox_s_8x8

if selection == 5:
  model_type = models.mmdet.yolof
  backbone = model_type.backbones.yolof_r50_c5_8x8_1x_coco

if selection == 6:
  model_type = models.mmdet.detr
  backbone = model_type.backbones.r50_8x2_150e_coco

if selection == 7:
  model_type = models.mmdet.deformable_detr
  backbone = model_type.backbones.twostage_refine_r50_16x2_50e_coco

if selection == 8:
  model_type = models.mmdet.fsaf
  backbone = model_type.backbones.x101_64x4d_fpn_1x_coco

if selection == 9:
  model_type = models.mmdet.sabl
  backbone = model_type.backbones.r101_fpn_gn_2x_ms_640_800_coco

if selection == 10:
  model_type = models.mmdet.centripetalnet
  backbone = model_type.backbones.hourglass104_mstest_16x6_210e_coco

elif selection == 11:
  # The Retinanet model is also implemented in the torchvision library
  model_type = models.torchvision.retinanet
  backbone = model_type.backbones.resnet50_fpn

elif selection == 12:
  model_type = models.ross.efficientdet
  backbone = model_type.backbones.tf_lite0
  # The efficientdet model requires an img_size parameter
  extra_args['img_size'] = image_size

elif selection == 13:
  model_type = models.ultralytics.yolov5
  backbone = model_type.backbones.small
  # The yolov5 model requires an img_size parameter
  extra_args['img_size'] = image_size

model_type, backbone, extra_args
(<module 'icevision.models.mmdet.models.vfnet' from '/usr/local/lib/python3.7/dist-packages/icevision/models/mmdet/models/vfnet/__init__.py'>,
 <icevision.models.mmdet.models.vfnet.backbones.backbone_config.MMDetVFNETBackboneConfig at 0x7f42166a1c10>,
 {})

backbone.__dict__
{'config_path': Path('/root/.icevision/mmdetection_configs/mmdetection_configs-2.20.1/configs/vfnet/vfnet_r50_fpn_mstrain_2x_coco.py'),
 'model_name': 'vfnet',
 'pretrained': True,
 'weights_url': 'https://download.openmmlab.com/mmdetection/v2.0/vfnet/vfnet_r50_fpn_mstrain_2x_coco/vfnet_r50_fpn_mstrain_2x_coco_20201027-7cc75bd2.pth'}
# Instantiate the model
model = model_type.model(backbone=backbone(pretrained=True), num_classes=len(parser.class_map), **extra_args)

/usr/local/lib/python3.7/dist-packages/mmdet/core/anchor/builder.py:17: UserWarning: ``build_anchor_generator`` would be deprecated soon, please use ``build_prior_generator`` 
  '``build_anchor_generator`` would be deprecated soon, please use '
2022-08-07 16:50:58,618 - mmcv - INFO - initialize ResNet with init_cfg {'type': 'Pretrained', 'checkpoint': 'torchvision://resnet50'}
2022-08-07 16:50:58,620 - mmcv - INFO - load model from: torchvision://resnet50
2022-08-07 16:50:58,621 - mmcv - INFO - load checkpoint from torchvision path: torchvision://resnet50
2022-08-07 16:50:58,731 - mmcv - WARNING - The model and loaded state dict do not match exactly

unexpected key in source state_dict: fc.weight, fc.bias

2022-08-07 16:50:58,763 - mmcv - INFO - initialize FPN with init_cfg {'type': 'Xavier', 'layer': 'Conv2d', 'distribution': 'uniform'}
2022-08-07 16:50:58,795 - mmcv - INFO - initialize VFNetHead with init_cfg {'type': 'Normal', 'layer': 'Conv2d', 'std': 0.01, 'override': {'type': 'Normal', 'name': 'vfnet_cls', 'std': 0.01, 'bias_prob': 0.01}}
2022-08-07 16:50:58,833 - mmcv - INFO - 
backbone.conv1.weight - torch.Size([64, 3, 7, 7]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,835 - mmcv - INFO - 
backbone.bn1.weight - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,839 - mmcv - INFO - 
backbone.bn1.bias - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,842 - mmcv - INFO - 
backbone.layer1.0.conv1.weight - torch.Size([64, 64, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,844 - mmcv - INFO - 
backbone.layer1.0.bn1.weight - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,847 - mmcv - INFO - 
backbone.layer1.0.bn1.bias - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,850 - mmcv - INFO - 
backbone.layer1.0.conv2.weight - torch.Size([64, 64, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,852 - mmcv - INFO - 
backbone.layer1.0.bn2.weight - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,855 - mmcv - INFO - 
backbone.layer1.0.bn2.bias - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,858 - mmcv - INFO - 
backbone.layer1.0.conv3.weight - torch.Size([256, 64, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,860 - mmcv - INFO - 
backbone.layer1.0.bn3.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,863 - mmcv - INFO - 
backbone.layer1.0.bn3.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,866 - mmcv - INFO - 
backbone.layer1.0.downsample.0.weight - torch.Size([256, 64, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,868 - mmcv - INFO - 
backbone.layer1.0.downsample.1.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,871 - mmcv - INFO - 
backbone.layer1.0.downsample.1.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,874 - mmcv - INFO - 
backbone.layer1.1.conv1.weight - torch.Size([64, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,877 - mmcv - INFO - 
backbone.layer1.1.bn1.weight - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,879 - mmcv - INFO - 
backbone.layer1.1.bn1.bias - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,883 - mmcv - INFO - 
backbone.layer1.1.conv2.weight - torch.Size([64, 64, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,886 - mmcv - INFO - 
backbone.layer1.1.bn2.weight - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,888 - mmcv - INFO - 
backbone.layer1.1.bn2.bias - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,890 - mmcv - INFO - 
backbone.layer1.1.conv3.weight - torch.Size([256, 64, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,892 - mmcv - INFO - 
backbone.layer1.1.bn3.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,894 - mmcv - INFO - 
backbone.layer1.1.bn3.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,896 - mmcv - INFO - 
backbone.layer1.2.conv1.weight - torch.Size([64, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,898 - mmcv - INFO - 
backbone.layer1.2.bn1.weight - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,901 - mmcv - INFO - 
backbone.layer1.2.bn1.bias - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,902 - mmcv - INFO - 
backbone.layer1.2.conv2.weight - torch.Size([64, 64, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,904 - mmcv - INFO - 
backbone.layer1.2.bn2.weight - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,905 - mmcv - INFO - 
backbone.layer1.2.bn2.bias - torch.Size([64]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,907 - mmcv - INFO - 
backbone.layer1.2.conv3.weight - torch.Size([256, 64, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,908 - mmcv - INFO - 
backbone.layer1.2.bn3.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,909 - mmcv - INFO - 
backbone.layer1.2.bn3.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,911 - mmcv - INFO - 
backbone.layer2.0.conv1.weight - torch.Size([128, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,912 - mmcv - INFO - 
backbone.layer2.0.bn1.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,914 - mmcv - INFO - 
backbone.layer2.0.bn1.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,916 - mmcv - INFO - 
backbone.layer2.0.conv2.weight - torch.Size([128, 128, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,918 - mmcv - INFO - 
backbone.layer2.0.bn2.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,920 - mmcv - INFO - 
backbone.layer2.0.bn2.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,922 - mmcv - INFO - 
backbone.layer2.0.conv3.weight - torch.Size([512, 128, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,923 - mmcv - INFO - 
backbone.layer2.0.bn3.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,926 - mmcv - INFO - 
backbone.layer2.0.bn3.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,927 - mmcv - INFO - 
backbone.layer2.0.downsample.0.weight - torch.Size([512, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,930 - mmcv - INFO - 
backbone.layer2.0.downsample.1.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,932 - mmcv - INFO - 
backbone.layer2.0.downsample.1.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,934 - mmcv - INFO - 
backbone.layer2.1.conv1.weight - torch.Size([128, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,936 - mmcv - INFO - 
backbone.layer2.1.bn1.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,938 - mmcv - INFO - 
backbone.layer2.1.bn1.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,940 - mmcv - INFO - 
backbone.layer2.1.conv2.weight - torch.Size([128, 128, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,942 - mmcv - INFO - 
backbone.layer2.1.bn2.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,944 - mmcv - INFO - 
backbone.layer2.1.bn2.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,946 - mmcv - INFO - 
backbone.layer2.1.conv3.weight - torch.Size([512, 128, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,948 - mmcv - INFO - 
backbone.layer2.1.bn3.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,950 - mmcv - INFO - 
backbone.layer2.1.bn3.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,951 - mmcv - INFO - 
backbone.layer2.2.conv1.weight - torch.Size([128, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,953 - mmcv - INFO - 
backbone.layer2.2.bn1.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,955 - mmcv - INFO - 
backbone.layer2.2.bn1.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,957 - mmcv - INFO - 
backbone.layer2.2.conv2.weight - torch.Size([128, 128, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,958 - mmcv - INFO - 
backbone.layer2.2.bn2.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,960 - mmcv - INFO - 
backbone.layer2.2.bn2.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,961 - mmcv - INFO - 
backbone.layer2.2.conv3.weight - torch.Size([512, 128, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,962 - mmcv - INFO - 
backbone.layer2.2.bn3.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,964 - mmcv - INFO - 
backbone.layer2.2.bn3.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,965 - mmcv - INFO - 
backbone.layer2.3.conv1.weight - torch.Size([128, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,967 - mmcv - INFO - 
backbone.layer2.3.bn1.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,968 - mmcv - INFO - 
backbone.layer2.3.bn1.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,969 - mmcv - INFO - 
backbone.layer2.3.conv2.weight - torch.Size([128, 128, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,971 - mmcv - INFO - 
backbone.layer2.3.bn2.weight - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,972 - mmcv - INFO - 
backbone.layer2.3.bn2.bias - torch.Size([128]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,974 - mmcv - INFO - 
backbone.layer2.3.conv3.weight - torch.Size([512, 128, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,976 - mmcv - INFO - 
backbone.layer2.3.bn3.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,977 - mmcv - INFO - 
backbone.layer2.3.bn3.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,978 - mmcv - INFO - 
backbone.layer3.0.conv1.weight - torch.Size([256, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,979 - mmcv - INFO - 
backbone.layer3.0.bn1.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,980 - mmcv - INFO - 
backbone.layer3.0.bn1.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,982 - mmcv - INFO - 
backbone.layer3.0.conv2.weight - torch.Size([256, 256, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,983 - mmcv - INFO - 
backbone.layer3.0.bn2.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,985 - mmcv - INFO - 
backbone.layer3.0.bn2.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,988 - mmcv - INFO - 
backbone.layer3.0.conv3.weight - torch.Size([1024, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,989 - mmcv - INFO - 
backbone.layer3.0.bn3.weight - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,991 - mmcv - INFO - 
backbone.layer3.0.bn3.bias - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,992 - mmcv - INFO - 
backbone.layer3.0.downsample.0.weight - torch.Size([1024, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,994 - mmcv - INFO - 
backbone.layer3.0.downsample.1.weight - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,995 - mmcv - INFO - 
backbone.layer3.0.downsample.1.bias - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,997 - mmcv - INFO - 
backbone.layer3.1.conv1.weight - torch.Size([256, 1024, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:58,998 - mmcv - INFO - 
backbone.layer3.1.bn1.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,000 - mmcv - INFO - 
backbone.layer3.1.bn1.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,001 - mmcv - INFO - 
backbone.layer3.1.conv2.weight - torch.Size([256, 256, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,003 - mmcv - INFO - 
backbone.layer3.1.bn2.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,004 - mmcv - INFO - 
backbone.layer3.1.bn2.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,006 - mmcv - INFO - 
backbone.layer3.1.conv3.weight - torch.Size([1024, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,007 - mmcv - INFO - 
backbone.layer3.1.bn3.weight - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,009 - mmcv - INFO - 
backbone.layer3.1.bn3.bias - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,010 - mmcv - INFO - 
backbone.layer3.2.conv1.weight - torch.Size([256, 1024, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,012 - mmcv - INFO - 
backbone.layer3.2.bn1.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,013 - mmcv - INFO - 
backbone.layer3.2.bn1.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,015 - mmcv - INFO - 
backbone.layer3.2.conv2.weight - torch.Size([256, 256, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,016 - mmcv - INFO - 
backbone.layer3.2.bn2.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,018 - mmcv - INFO - 
backbone.layer3.2.bn2.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,019 - mmcv - INFO - 
backbone.layer3.2.conv3.weight - torch.Size([1024, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,021 - mmcv - INFO - 
backbone.layer3.2.bn3.weight - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,022 - mmcv - INFO - 
backbone.layer3.2.bn3.bias - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,024 - mmcv - INFO - 
backbone.layer3.3.conv1.weight - torch.Size([256, 1024, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,026 - mmcv - INFO - 
backbone.layer3.3.bn1.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,027 - mmcv - INFO - 
backbone.layer3.3.bn1.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,029 - mmcv - INFO - 
backbone.layer3.3.conv2.weight - torch.Size([256, 256, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,030 - mmcv - INFO - 
backbone.layer3.3.bn2.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,032 - mmcv - INFO - 
backbone.layer3.3.bn2.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,033 - mmcv - INFO - 
backbone.layer3.3.conv3.weight - torch.Size([1024, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,035 - mmcv - INFO - 
backbone.layer3.3.bn3.weight - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,036 - mmcv - INFO - 
backbone.layer3.3.bn3.bias - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,038 - mmcv - INFO - 
backbone.layer3.4.conv1.weight - torch.Size([256, 1024, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,039 - mmcv - INFO - 
backbone.layer3.4.bn1.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,041 - mmcv - INFO - 
backbone.layer3.4.bn1.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,042 - mmcv - INFO - 
backbone.layer3.4.conv2.weight - torch.Size([256, 256, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,044 - mmcv - INFO - 
backbone.layer3.4.bn2.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,045 - mmcv - INFO - 
backbone.layer3.4.bn2.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,047 - mmcv - INFO - 
backbone.layer3.4.conv3.weight - torch.Size([1024, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,048 - mmcv - INFO - 
backbone.layer3.4.bn3.weight - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,050 - mmcv - INFO - 
backbone.layer3.4.bn3.bias - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,051 - mmcv - INFO - 
backbone.layer3.5.conv1.weight - torch.Size([256, 1024, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,053 - mmcv - INFO - 
backbone.layer3.5.bn1.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,055 - mmcv - INFO - 
backbone.layer3.5.bn1.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,056 - mmcv - INFO - 
backbone.layer3.5.conv2.weight - torch.Size([256, 256, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,058 - mmcv - INFO - 
backbone.layer3.5.bn2.weight - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,059 - mmcv - INFO - 
backbone.layer3.5.bn2.bias - torch.Size([256]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,061 - mmcv - INFO - 
backbone.layer3.5.conv3.weight - torch.Size([1024, 256, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,062 - mmcv - INFO - 
backbone.layer3.5.bn3.weight - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,064 - mmcv - INFO - 
backbone.layer3.5.bn3.bias - torch.Size([1024]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,065 - mmcv - INFO - 
backbone.layer4.0.conv1.weight - torch.Size([512, 1024, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,067 - mmcv - INFO - 
backbone.layer4.0.bn1.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,068 - mmcv - INFO - 
backbone.layer4.0.bn1.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,070 - mmcv - INFO - 
backbone.layer4.0.conv2.weight - torch.Size([512, 512, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,071 - mmcv - INFO - 
backbone.layer4.0.bn2.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,073 - mmcv - INFO - 
backbone.layer4.0.bn2.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,074 - mmcv - INFO - 
backbone.layer4.0.conv3.weight - torch.Size([2048, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,076 - mmcv - INFO - 
backbone.layer4.0.bn3.weight - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,077 - mmcv - INFO - 
backbone.layer4.0.bn3.bias - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,079 - mmcv - INFO - 
backbone.layer4.0.downsample.0.weight - torch.Size([2048, 1024, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,080 - mmcv - INFO - 
backbone.layer4.0.downsample.1.weight - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,082 - mmcv - INFO - 
backbone.layer4.0.downsample.1.bias - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,083 - mmcv - INFO - 
backbone.layer4.1.conv1.weight - torch.Size([512, 2048, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,085 - mmcv - INFO - 
backbone.layer4.1.bn1.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,086 - mmcv - INFO - 
backbone.layer4.1.bn1.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,088 - mmcv - INFO - 
backbone.layer4.1.conv2.weight - torch.Size([512, 512, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,089 - mmcv - INFO - 
backbone.layer4.1.bn2.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,091 - mmcv - INFO - 
backbone.layer4.1.bn2.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,093 - mmcv - INFO - 
backbone.layer4.1.conv3.weight - torch.Size([2048, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,094 - mmcv - INFO - 
backbone.layer4.1.bn3.weight - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,096 - mmcv - INFO - 
backbone.layer4.1.bn3.bias - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,097 - mmcv - INFO - 
backbone.layer4.2.conv1.weight - torch.Size([512, 2048, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,099 - mmcv - INFO - 
backbone.layer4.2.bn1.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,100 - mmcv - INFO - 
backbone.layer4.2.bn1.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,102 - mmcv - INFO - 
backbone.layer4.2.conv2.weight - torch.Size([512, 512, 3, 3]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,103 - mmcv - INFO - 
backbone.layer4.2.bn2.weight - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,105 - mmcv - INFO - 
backbone.layer4.2.bn2.bias - torch.Size([512]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,106 - mmcv - INFO - 
backbone.layer4.2.conv3.weight - torch.Size([2048, 512, 1, 1]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,108 - mmcv - INFO - 
backbone.layer4.2.bn3.weight - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,110 - mmcv - INFO - 
backbone.layer4.2.bn3.bias - torch.Size([2048]): 
PretrainedInit: load from torchvision://resnet50 
 
2022-08-07 16:50:59,112 - mmcv - INFO - 
neck.lateral_convs.0.conv.weight - torch.Size([256, 512, 1, 1]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,113 - mmcv - INFO - 
neck.lateral_convs.0.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,115 - mmcv - INFO - 
neck.lateral_convs.1.conv.weight - torch.Size([256, 1024, 1, 1]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,116 - mmcv - INFO - 
neck.lateral_convs.1.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,118 - mmcv - INFO - 
neck.lateral_convs.2.conv.weight - torch.Size([256, 2048, 1, 1]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,120 - mmcv - INFO - 
neck.lateral_convs.2.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,121 - mmcv - INFO - 
neck.fpn_convs.0.conv.weight - torch.Size([256, 256, 3, 3]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,123 - mmcv - INFO - 
neck.fpn_convs.0.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,124 - mmcv - INFO - 
neck.fpn_convs.1.conv.weight - torch.Size([256, 256, 3, 3]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,126 - mmcv - INFO - 
neck.fpn_convs.1.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,127 - mmcv - INFO - 
neck.fpn_convs.2.conv.weight - torch.Size([256, 256, 3, 3]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,129 - mmcv - INFO - 
neck.fpn_convs.2.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,130 - mmcv - INFO - 
neck.fpn_convs.3.conv.weight - torch.Size([256, 256, 3, 3]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,132 - mmcv - INFO - 
neck.fpn_convs.3.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,133 - mmcv - INFO - 
neck.fpn_convs.4.conv.weight - torch.Size([256, 256, 3, 3]): 
XavierInit: gain=1, distribution=uniform, bias=0 
 
2022-08-07 16:50:59,135 - mmcv - INFO - 
neck.fpn_convs.4.conv.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,136 - mmcv - INFO - 
bbox_head.cls_convs.0.conv.weight - torch.Size([256, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,138 - mmcv - INFO - 
bbox_head.cls_convs.0.gn.weight - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,140 - mmcv - INFO - 
bbox_head.cls_convs.0.gn.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,141 - mmcv - INFO - 
bbox_head.cls_convs.1.conv.weight - torch.Size([256, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,143 - mmcv - INFO - 
bbox_head.cls_convs.1.gn.weight - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,144 - mmcv - INFO - 
bbox_head.cls_convs.1.gn.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,146 - mmcv - INFO - 
bbox_head.cls_convs.2.conv.weight - torch.Size([256, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,147 - mmcv - INFO - 
bbox_head.cls_convs.2.gn.weight - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,149 - mmcv - INFO - 
bbox_head.cls_convs.2.gn.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,150 - mmcv - INFO - 
bbox_head.reg_convs.0.conv.weight - torch.Size([256, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,152 - mmcv - INFO - 
bbox_head.reg_convs.0.gn.weight - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,153 - mmcv - INFO - 
bbox_head.reg_convs.0.gn.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,155 - mmcv - INFO - 
bbox_head.reg_convs.1.conv.weight - torch.Size([256, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,156 - mmcv - INFO - 
bbox_head.reg_convs.1.gn.weight - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,158 - mmcv - INFO - 
bbox_head.reg_convs.1.gn.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,159 - mmcv - INFO - 
bbox_head.reg_convs.2.conv.weight - torch.Size([256, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,161 - mmcv - INFO - 
bbox_head.reg_convs.2.gn.weight - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,162 - mmcv - INFO - 
bbox_head.reg_convs.2.gn.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,164 - mmcv - INFO - 
bbox_head.vfnet_reg_conv.conv.weight - torch.Size([256, 256, 3, 3]): 
Initialized by user-defined `init_weights` in ConvModule  
 
2022-08-07 16:50:59,166 - mmcv - INFO - 
bbox_head.vfnet_reg_conv.gn.weight - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,167 - mmcv - INFO - 
bbox_head.vfnet_reg_conv.gn.bias - torch.Size([256]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,169 - mmcv - INFO - 
bbox_head.vfnet_reg.weight - torch.Size([4, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,170 - mmcv - INFO - 
bbox_head.vfnet_reg.bias - torch.Size([4]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,172 - mmcv - INFO - 
bbox_head.scales.0.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,173 - mmcv - INFO - 
bbox_head.scales.1.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,175 - mmcv - INFO - 
bbox_head.scales.2.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,176 - mmcv - INFO - 
bbox_head.scales.3.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,178 - mmcv - INFO - 
bbox_head.scales.4.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,180 - mmcv - INFO - 
bbox_head.vfnet_reg_refine_dconv.weight - torch.Size([256, 256, 3, 3]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,181 - mmcv - INFO - 
bbox_head.vfnet_reg_refine.weight - torch.Size([4, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,183 - mmcv - INFO - 
bbox_head.vfnet_reg_refine.bias - torch.Size([4]): 
NormalInit: mean=0, std=0.01, bias=0 
 
2022-08-07 16:50:59,185 - mmcv - INFO - 
bbox_head.scales_refine.0.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,186 - mmcv - INFO - 
bbox_head.scales_refine.1.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,188 - mmcv - INFO - 
bbox_head.scales_refine.2.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,189 - mmcv - INFO - 
bbox_head.scales_refine.3.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,191 - mmcv - INFO - 
bbox_head.scales_refine.4.scale - torch.Size([]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,192 - mmcv - INFO - 
bbox_head.vfnet_cls_dconv.weight - torch.Size([256, 256, 3, 3]): 
The value is the same before and after calling `init_weights` of VFNet  
 
2022-08-07 16:50:59,194 - mmcv - INFO - 
bbox_head.vfnet_cls.weight - torch.Size([4, 256, 3, 3]): 
NormalInit: mean=0, std=0.01, bias=-4.59511985013459 
 
2022-08-07 16:50:59,195 - mmcv - INFO - 
bbox_head.vfnet_cls.bias - torch.Size([4]): 
NormalInit: mean=0, std=0.01, bias=-4.59511985013459 
 
load checkpoint from local path: checkpoints/vfnet/vfnet_r50_fpn_mstrain_2x_coco_20201027-7cc75bd2.pth
The model and loaded state dict do not match exactly

size mismatch for bbox_head.vfnet_cls.weight: copying a param with shape torch.Size([80, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([4, 256, 3, 3]).
size mismatch for bbox_head.vfnet_cls.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([4]).

Data Loader

'The Data Loader is specific to a model_type. The job of the data loader is to get items from a dataset and batch them up in the specific format required by each model. This is why creating the data loaders is separated from creating the datasets. We can take a look at the first batch of items from the valid_dl. Remember that the valid_tfms only resized (with padding) and normalized records, so different images, for example, are not returned each time. This is important to provide consistent validation during training'

train_dl = model_type.train_dl(train_ds, batch_size=8, num_workers=4, shuffle=True)
valid_dl = model_type.valid_dl(valid_ds, batch_size=8, num_workers=4, shuffle=False)
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:481: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  cpuset_checked))

Let's visualize a batch of images.

model_type.show_batch(first(valid_dl), ncols=4)
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:481: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  cpuset_checked))

Metrics

'The fastai and pytorch lightning engines collect metrics to track progress during training. IceVision provides metric classes that work across the engines and libraries. The same metrics can be used for both fastai and pytorch lightning.'

metrics = [COCOMetric(metric_type=COCOMetricType.bbox)]

Training

IceVision is an agnostic framework meaning it can be plugged into other DL learning engines such as fastai, and pytorch-lightning.This makes it so convenient and easy to train models.This also means we can use specific engines' callback systems.

Training using fastai

learn = model_type.fastai.learner(dls=[train_dl, valid_dl], model=model, metrics=metrics)
lr = learn.lr_find()[0]
/usr/local/lib/python3.7/dist-packages/mmdet/core/anchor/anchor_generator.py:324: UserWarning: ``grid_anchors`` would be deprecated soon. Please use ``grid_priors`` 
  warnings.warn('``grid_anchors`` would be deprecated soon. '
/usr/local/lib/python3.7/dist-packages/mmdet/core/anchor/anchor_generator.py:361: UserWarning: ``single_level_grid_anchors`` would be deprecated soon. Please use ``single_level_grid_priors`` 
  '``single_level_grid_anchors`` would be deprecated soon. '

lr
0.00019054606673307717
learn.fine_tune(20, lr, freeze_epochs=1)
epoch train_loss valid_loss COCOMetric time
0 3.595542 2.214065 0.419581 00:09
/usr/local/lib/python3.7/dist-packages/mmdet/core/anchor/anchor_generator.py:324: UserWarning: ``grid_anchors`` would be deprecated soon. Please use ``grid_priors`` 
  warnings.warn('``grid_anchors`` would be deprecated soon. '
/usr/local/lib/python3.7/dist-packages/mmdet/core/anchor/anchor_generator.py:361: UserWarning: ``single_level_grid_anchors`` would be deprecated soon. Please use ``single_level_grid_priors`` 
  '``single_level_grid_anchors`` would be deprecated soon. '
epoch train_loss valid_loss COCOMetric time
0 2.084602 1.634030 0.470653 00:10
1 1.858727 1.432253 0.444948 00:10
2 1.676041 1.159493 0.714662 00:10
3 1.521851 1.004197 0.796917 00:10
4 1.398202 0.944683 0.839429 00:10
5 1.288910 0.837564 0.897281 00:10
6 1.186669 0.767936 0.898159 00:10
7 1.098148 0.754201 0.922980 00:10
8 1.030176 0.718864 0.897819 00:10
9 0.975276 0.705527 0.907615 00:10
10 0.925214 0.657741 0.933411 00:10
11 0.877626 0.652339 0.924390 00:10
12 0.849741 0.627645 0.933406 00:10
13 0.819354 0.635671 0.912690 00:10
14 0.794682 0.595221 0.925068 00:10
15 0.769964 0.593487 0.931168 00:10
16 0.744934 0.591581 0.927655 00:10
17 0.724243 0.589162 0.927391 00:10
18 0.707685 0.586102 0.930337 00:10
19 0.686125 0.585268 0.930337 00:10

Training with pytorch lightning is extremely easy aswell.

Uncomment below lines to train with lightning.

# class LightModel(model_type.lightning.ModelAdapter):
#   def configure_optimizers(self):
#     return Adam(self.parameters(), lr=1e-4)  
# light_model = LightModel(model, metrics=metrics)
# trainer = pl.Trainer(max_epochs=5, gpus=1)
# trainer.fit(light_model, train_dl, valid_dl)

Showing Results

'The first step in reviewing the model is to show results from the validation dataset. This is easy to do with the show_results function.'

model_type.show_results(model, valid_ds, detection_threshold=0.5)

Prediction

'Sometimes you want to have more control than show_results provides. You can construct an inference dataloader using infer_dl from any IceVision dataset and pass this to predict_dl and use show_preds to look at the predictions.

A prediction is returned as a dict with keys: scores, labels, bboxes, and possibly masks.

Prediction functions that take a detection_threshold argument will only return the predictions whose score is above the threshold.

Prediction functions that take a keep_images argument will only return the (tensor representation of the) image when it is True. In interactive environments, such as a notebook, it is helpful to see the image with bounding boxes and labels applied. In a deployment context, however, it is typically more useful (and efficient) to return the bounding boxes by themselves.'

infer_dl = model_type.infer_dl(valid_ds, batch_size=4, shuffle=False)
preds = model_type.predict_from_dl(model, infer_dl, keep_images=True)
show_preds(preds=preds[:4])

Saving Our Model

For saving our model we need to import 'from icevision.models import *'.

from icevision.models import *
checkpoint_path = "/content/FridgeObjectsVfnet-ckpt.pth" #Path to save our model with model name
checkpoint_and_model = save_icevision_checkpoint(model, #our trained model
    filename = checkpoint_path, 
    model_name='mmdet.vfnet', #our model name 
    backbone_name='resnet50_fpn_mstrain_2x', #our model's backbone
    img_size=384, #our image size
    classes =  parser.class_map.get_classes() #our classnames
    )

Loading Our Model

checkpoint_path = '/content/FridgeObjectsVfnet-ckpt.pth'

checkpoint_and_model = model_from_checkpoint(checkpoint_path)
# Just logging the info
model_type = checkpoint_and_model["model_type"]
backbone = checkpoint_and_model["backbone"] 
class_map = checkpoint_and_model["class_map"] #our classes
img_size = checkpoint_and_model["img_size"] #our image size
model_type, backbone, class_map, img_size
model = checkpoint_and_model["model"]
# Transforms
img_size = checkpoint_and_model["img_size"]
valid_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(img_size), tfms.A.Normalize()])

Single Image Inference

!wget https://img.merkandi.com.tr/imgcache/800x600/offer/whatsapp-image-2022-04-18-at-100915-1650299189-1650299201.jpeg #lets grab an image from google
image = PIL.Image.open("/content/whatsapp-image-2022-04-18-at-100915-1650299189-1650299201.jpeg")
pred_dict  = model_type.end2end_detect(image, valid_tfms, model, class_map=class_map, detection_threshold=0.5) #don't forget to play with detection_threshold !
pred_dict['img']

Batch Inference

infer_ds = Dataset.from_images([image for i in range(4)], valid_tfms, class_map=class_map) #our image repeated four times
infer_dl = model_type.infer_dl(infer_ds , batch_size=4, shuffle=False)
preds = model_type.predict_from_dl(model, infer_dl, keep_images=True)
show_preds(preds=preds[0:4])